Skip to content

v0.3 - #9

Open
tehwave wants to merge 15 commits into
mainfrom
codex/merchant-selection
Open

tehwave wants to merge 15 commits into
mainfrom
codex/merchant-selection

Conversation

@tehwave

@tehwave tehwave commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Replaces single-key authentication with named, saved merchants, so one install can work with several Quickpay merchants and each project can choose its own. Any saved merchant can also be made read-only.

Added

  • Named merchants. merchants:add, merchants:list, merchants:select, merchants:active and merchants:remove save and choose between several merchants. Every authenticated command takes --merchant.
  • Project bindings. merchants:select <name> --local writes .quickpay-cli.json, so commands in that folder and below use that merchant.
  • Read-only merchants. merchants:add --read-only or merchants:access --read-only blocks every request except GET before anything is sent. merchants:access --read-write allows writes again, and only after a confirmation in an interactive terminal, so a script or agent can't undo it.
  • Payment mutations, payment creation, raw mutations and callback watching name the merchant they use.
  • callbacks:watch and callbacks:replay warn when QUICKPAY_PRIVATE_KEY is set while a saved merchant is selected, since it may belong to another merchant.

Changed

  • The bundled agent skill is renamed from quickpay to quickpay-cli.
  • Symfony is updated to 7.4.22 and 7.4.23 within the existing constraints, clearing seven composer audit advisories that failed the Package metadata check.

Breaking

  • The login, logout and auth commands are removed. Save a merchant with quickpay merchants:add <name>, and use merchants:active --check instead of auth --check.
  • ~/.config/quickpay/config.json is no longer read. Add the merchant again with merchants:add, then delete the old file. merchants:add reminds you while it still exists.

Testing

composer check passes: the Pest suite, PHPStan and Pint.

🤖 Generated with Claude Code

Extend the distribution contract coverage for the packaged binary by asserting that the bundled Flysystem rejects malformed paths while still normalizing valid paths as expected. This also captures the related Flysystem lockfile update that the new assertions depend on.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The broad security-sensitive credential migration, locking behavior, selection precedence, and packaged-runtime impact require final human verification.

Review effort: Balanced
Findings: None

What changed in this PR

Introduces multi-merchant credential storage and selection for Quickpay CLI, replacing the previous single-credential authentication workflow.

Changes:

  • Adds secure named merchant storage, project bindings, explicit selection, and merchant management commands.
  • Pins authenticated clients to resolved credentials and surfaces merchant context for sensitive operations.
  • Updates documentation, tests, the bundled skill, and Flysystem.
File Description
tests/​Unit/​Credentials/​MerchantNameTest.php Tests merchant-name validation.
tests/​Unit/​Credentials/​MerchantConfigurationJsonTest.php Tests duplicate JSON-property detection.
tests/​Unit/​Credentials/​ApiKeyResolverTest.php Tests credential-selection precedence and conflicts.
tests/​Integration/​Credentials/​ProjectMerchantFileTest.php Tests project binding discovery and validation.
tests/​Integration/​Credentials/​MerchantStoreTest.php Tests secure, atomic merchant persistence.
tests/​Integration/​Credentials/​CredentialFileTest.php Removes obsolete single-credential tests.
tests/​Feature/​Quickpay/​MerchantAuthenticationCheckTest.php Tests merchant-scope validation.
tests/​Feature/​Quickpay/​AuthenticatedQuickpayFactoryTest.php Tests pinned authenticated credentials.
tests/​Feature/​Console/​AuthenticatedCommandTest.php Covers merchant-aware authenticated commands.
tests/​Feature/​Commands/​Payments/​PaymentMutationCommandsTest.php Isolates project selection in mutation tests.
tests/​Feature/​Commands/​Payments/​ListPaymentsCommandTest.php Adapts missing-credential behavior and setup.
tests/​Feature/​Commands/​Payments/​GetPaymentCommandTest.php Isolates project selection.
tests/​Feature/​Commands/​Payments/​CreatePaymentLinkCommandTest.php Isolates project selection.
tests/​Feature/​Commands/​Payments/​CreatePaymentCommandTest.php Isolates project selection.
tests/​Feature/​Commands/​Merchants/​MerchantCommandsTest.php Covers merchant-management workflows.
tests/​Feature/​Commands/​Callbacks/​WatchCallbacksCommandTest.php Isolates callback project selection.
tests/​Feature/​Commands/​Callbacks/​ReplayCallbackCommandTest.php Isolates callback project selection.
tests/​Feature/​Commands/​Authentication/​AuthenticationCommandsTest.php Removes superseded authentication tests.
tests/​Feature/​Commands/​Api/​ApiRequestCommandTest.php Isolates raw API project selection.
tests/​Feature/​CommandHelpTest.php Verifies merchant options and skill commands.
tests/​Feature/​ApplicationIdentityTest.php Updates the public command inventory.
tests/​Architecture/​SkillContractTest.php Validates bundled skill naming and references.
tests/​Architecture/​DistributionContractTest.php Tests updated Flysystem path handling.
skills/​quickpay-cli/​SKILL.md Documents merchant-aware agent workflows.
SECURITY.md Documents credential and selection invariants.
README.md Documents merchant setup and usage.
CONTRIBUTING.md Updates the skill path.
composer.lock Updates Flysystem to 3.35.3.
app/​Quickpay/​MerchantAuthenticationCheck.php Adds merchant-scope authentication checks.
app/​Quickpay/​AuthenticatedQuickpayFactory.php Supports explicit merchant resolution.
app/​Providers/​AppServiceProvider.php Registers the new credential services.
app/​Credentials/​ProjectMerchantFile.php Implements project merchant bindings.
app/​Credentials/​MerchantStore.php Implements locked named-credential storage.
app/​Credentials/​MerchantName.php Validates merchant labels.
app/​Credentials/​MerchantConfigurationJson.php Rejects ambiguous duplicate properties.
app/​Credentials/​CredentialFile.php Removes single-credential persistence.
app/​Credentials/​ApiKeyResolver.php Implements merchant-selection precedence.
app/​Credentials/​ApiKey.php Carries merchant-selection context.
app/​Console/​AuthenticatedCommand.php Adds --merchant and context output.
app/​Commands/​Payments/​AbstractPaymentMutationCommand.php Adds merchant details to confirmations.
app/​Commands/​Merchants/​SelectMerchantCommand.php Adds global and project selection.
app/​Commands/​Merchants/​RemoveMerchantCommand.php Adds credential removal.
app/​Commands/​Merchants/​ListMerchantsCommand.php Adds merchant listing.
app/​Commands/​Merchants/​AddMerchantCommand.php Adds validated credential enrollment.
app/​Commands/​Merchants/​ActiveMerchantCommand.php Adds local and checked status reporting.
app/​Commands/​Callbacks/​WatchCallbacksCommand.php Reports pinned watcher context.
app/​Commands/​Authentication/​LogoutCommand.php Removes obsolete logout command.
app/​Commands/​Authentication/​LoginCommand.php Removes obsolete login command.
app/​Commands/​Authentication/​AuthCommand.php Removes obsolete auth command.
app/​Commands/​Api/​ApiRequestCommand.php Reports merchant context for mutations.
AGENTS.md Updates repository guidance and invariants.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

tehwave and others added 9 commits November 23, 2026 12:03
Split the merchant command feature tests into one file per command with
shared helpers in tests/Pest.php, simplify the merchant and credential
code paths, and trim the README and bundled skill.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Make the duplicate-property scan in merchant configuration JSON
  immune to regex backtracking limits and reject the file if it fails
- Reject project merchant bindings not owned by the current user
- Refuse merchants:add --replace for a merchant that is not saved
- Point to merchants:select when no default merchant is selected, and
  say so after merchants:remove clears the default
- Warn after merchants:add that the old single-key config file is
  unused and can be deleted, without reading it
- Print the merchant context for payments:create and payments:link
- Name the binding file in binding errors and give stale bindings
  their own message
- Show "Merchant: none" in merchants:active without credentials and
  drop the constant API base URL and version lines from its human output

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each saved merchant stores read and write flags. QuickpayClient refuses
any request they block before sending it: GET is a read and every other
method is a write. Capture, refund, cancel and raw mutations check access
before inspecting a payment or asking for confirmation. The credential
check behind merchants:add and merchants:active --check is exempt.

merchants:add takes --no-read and --no-write, and the new
merchants:access command shows or changes the flags. Blocking works
anywhere; allowing requests again needs an interactive terminal and a
confirmation. merchants:list and merchants:active report the flags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hant

callbacks:watch and callbacks:replay now print a warning when the
QUICKPAY_PRIVATE_KEY override is set while a saved merchant is selected,
since the override may belong to a different merchant than the one in
use. The warning goes to stderr in --json mode and is skipped for the
QUICKPAY_API_KEY environment key, where pairing the two is deliberate.

Also records the branch in the CHANGELOG, with the removed login,
logout and auth commands and the old config file marked as breaking.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
composer audit flagged seven advisories in symfony/http-foundation,
symfony/http-kernel and symfony/mime. This moves them to 7.4.23,
7.4.23 and 7.4.22, with their dependencies, within the existing
constraints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- merchants:add --replace now asks before a --read or --write flag
  lifts a saved block, and prints the access whenever it changes.
- merchants:access only asks when a flag lifts a block, so scripts can
  block with --read --no-write. Allowing what is already allowed is
  dropped, so it cannot undo a block saved in the meantime. A declined
  allow still applies the blocks requested with it.
- callbacks:watch checks read access before announcing the watch.
- The label for both flags off is now "reads and writes blocked", so
  it no longer contradicts the credential check.
- README and SECURITY.md say that a running callbacks:watch keeps the
  flags it started with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Blocking reads protected little and cost a lot: capture, refund,
cancel and callbacks all need reads, and most access edge cases came
from it. Saved merchants now carry a single write flag, and a
read-only merchant may send only GET.

- Removes --read and --no-read from merchants:add and merchants:access.
- The saved config is {"api_key": ..., "write": bool}; a read flag is
  rejected like any other extra field.
- merchants:list and merchants:active report write only.
- Drops the ping exemption and the read check in callbacks:watch,
  which only existed for merchants that blocked reads.
- Blocked writes now fail with "The selected merchant is read-only".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--no-write came from Symfony's negation of a write option, which is not
what anyone looks for. The protection now uses the common read-only
name.

- merchants:add <name> --read-only and merchants:access <name>
  --read-only make a merchant read-only.
- merchants:access <name> --read-write allows writes again after a
  confirmation in an interactive terminal; giving both flags fails.
- merchants:add --replace keeps a read-only merchant read-only, so
  merchants:access is the only way to allow writes again.
- The saved config and the JSON output use read_only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Applied by a code review run that was stopped before it reported its
findings; every change passes the full test suite.

- merchants:add refuses a name that differs from a saved one only in
  capitalization, in the command and under the store lock.
- A symlinked .quickpay-cli.json owned by another user is refused, not
  only the file it points to.
- merchants:add notes when QUICKPAY_API_KEY will still override saved
  merchants, and merchants:select says when a project binding still
  wins in the current folder.
- Config errors say when a file repeats a property.
- Docs cover re-adding a read-only merchant, what .quickpay-cli.json
  holds, and removing the old quickpay skill folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants